import Vuex from 'vuex';
import Vue from 'vue';
import api from './api/index.js';
Vue.use(Vuex);

let store = new Vuex.Store({
    state: {
        data: [],
        total: 0,
        pageSize: 1
    },
    mutations: {
        search(state, res) {
            state.data = res.data;
            state.total = res.total;
        }
    },
    actions: {
        search({commit}) {
            api.search(res => {
                commit('search', res);
            });
        }
    }
});
store.dispatch('search');
export default store;